package com.duan.controller;

import com.duan.pojo.ResponseResult;
import com.duan.pojo.Result;
import com.duan.pojo.SysUser;
import com.duan.pojo.vo.SysUserVO;
import com.duan.service.UserService;
import com.duan.validatedGroup.CreateUserGroup;
import com.duan.validatedGroup.UpdateUserGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author db
 * @version 1.0
 * @description UserController
 * @since 2024/4/15
 */
@RestController
@RequestMapping("/user")

public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/addUser")
    public ResponseResult addUser(@RequestBody @Validated(value = CreateUserGroup.class) SysUserVO sysUserVO){
        userService.addUser(sysUserVO);
        return ResponseResult.okResult();
    }

    @PostMapping("/updateUser")
    public ResponseResult updateUser(@RequestBody @Validated(value = UpdateUserGroup.class) SysUserVO sysUserVO){
        userService.updateUser(sysUserVO);
        return ResponseResult.okResult();
    }
}
